<?php

namespace App\Console\Commands;

use App\Models\OrderChild;
use App\Rep\ProductRep;
use Illuminate\Console\Command;

class UpdateChildSort extends Command
{
    /**
     * The name and signature of the console command.
     * php artisan command:updatechildsort
     * @var string
     */
    protected $signature = 'command:updatechildsort';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $list = OrderChild::where('is_del',2)->with('order')->get();
        foreach($list as $k=>$v){

            $sort = (new ProductRep())->getProductJobTypeListSortRep($v->order->product_id,$v->job_type_id);
            $v->sort = $sort;
            $v->save();
            $this->info('order_id='.$v->order_id.';order_child_id='.$v->id.";job_type_id=".$v->job_type_id.";工种：".$v->job_type->job_type.";sort=".$sort);

        }
    }
}
